﻿using Microsoft.OpenApi.Extensions;
using System.ComponentModel;

namespace TyNetCoreBlog.Helpers
{
    public class ResponseMsg
    {
        public ApiStatus status { get; private set; }
        public string message { get; private set; }
        public dynamic data { get; private set; }



        public ResponseMsg(ApiStatus statusCode)
        {
            this.status = statusCode;
            this.message = statusCode.GetDescription();
        }
        public ResponseMsg(ApiStatus statusCode, string message)
        {
            this.status = statusCode;
            this.message = message;
        }
        
        public ResponseMsg(ApiStatus statusCode, dynamic data, string message)
        {
            this.status = statusCode;
            this.message = message;
            this.data = data;
        }
        public ResponseMsg(ApiStatus statusCode, dynamic data)
        {
            this.status = statusCode;
            this.data = data;
            this.message = statusCode.GetDescription();
        }
        



        public enum ApiStatus
        {
            /// <summary>
            /// 成功
            /// </summary>
            [Description("成功")]
            OK = 200,

            /// <summary>
            /// 接受但未处理
            /// </summary>
            [Description("接受但未处理")]
            Accepted = 202,

            /// <summary>
            /// 语法错误
            /// </summary>
            [Description("请求语法错误")]
            BadRequest = 400,

            /// <summary>
            /// 未授权
            /// </summary>
            [Description("未授权")]
            Unauthorized = 401,

            /// <summary>
            /// 拒绝执行
            /// </summary>
            [Description("拒绝执行请求")]
            Forbidden = 403,

            /// <summary>
            /// 资源未找到
            /// </summary>
            [Description("资源未找到")]
            NotFound = 404,

            /// <summary>
            /// 失败、故障
            /// </summary>
            [Description("失败")]
            Fail = 500,


            //自定义==========================
            /// <summary>
            /// 资源已存在
            /// </summary>
            [Description("资源已存在")]
            AlreadyExists = 600,



        }

    }
}